from django.urls import re_path

from meiduo_admin.views import users, statistical, skus, permissions

urlpatterns = [
    # 进行url配置
    re_path(r'^authorizations/$', users.AdminAuthorizeView.as_view()),
    # 日活跃用户统计
    re_path(r'^statistical/day_active/$', statistical.UserDayActiveView.as_view()),
    # 日下单用户量统计
    re_path(r'^statistical/day_orders/$', statistical.UserDayOrdersView.as_view()),
    # 近30天每日新增用户统计
    re_path(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 用户管理
    re_path(r'^users/$', users.UserInfoView.as_view()),

    # SKU图片
    # re_path(r'^skus/images/$', skus.SKUImageViewSet.as_view({
    #     'get': 'list',
    #     'post': 'create'
    # })),
    # 图片管理
    re_path(r'^skus/simple/$', skus.SKUSimpleView.as_view()),
    # 获取指定图片数据
    # re_path(r'^skus/images/(?P<pk>\d+)/$', skus.SKUImageViewSet.as_view({
    #     'get': 'retrieve',
    #     'put': 'update',
    #     'delete': 'destroy'
    # })),

    # 权限管理
    # re_path(r'^permission/perms/$', permissions.PermissionViewSet.as_view({
    #     'get': 'list',
    #     'post': 'create'
    #
    # })),
    # re_path(r'^permission/perms/(?P<pk>\d+)/$', permissions.PermissionViewSet.as_view({
    #     'get': 'retrieve',
    #     'put': 'update',
    #     'delete': 'destroy'

    # })),
    re_path(r'^permission/content_types/$', permissions.PermissionViewSet.as_view({
        'get': 'content_types'
    })),

    # 用户组管理
    re_path(r'^permission/simple/$', permissions.GroupViewSet.as_view({
        'get': 'simple'
    })),

    # 管理员管理
    # re_path(r'^permission/admins/$', permissions.AdminViewSet.as_view({
    #     'get': 'list'
    #
    # })),
    re_path(r'^permission/groups/simple/$', permissions.AdminViewSet.as_view({
        'get': 'simple'
    })),

]

# 路由Router
from rest_framework.routers import SimpleRouter

# 获取图片
router = SimpleRouter()
router.register('skus/images', skus.SKUImageViewSet, basename='images')
urlpatterns += router.urls

# 权限管理
router = SimpleRouter()
router.register('permission/perms', permissions.PermissionViewSet, basename='perms')
urlpatterns += router.urls

# 用户组管理
router = SimpleRouter()
router.register('permission/groups', permissions.GroupViewSet, basename='groups')
urlpatterns += router.urls

# 管理员管理
router = SimpleRouter()
router.register('permission/admins', permissions.AdminViewSet, basename='admins')
urlpatterns += router.urls
